<template>
  <NavBar
    :title="title"
    :leftArrow="false" />

  <div class="body">
    <div class="info">
      <div class="avatar">
        <image
          :src="
            userInfo ? globalParams.baseUrl + userInfo.imgUrl : defaultAvatar
          "
          mode="aspectFit" />
      </div>
      <div class="name">{{ userInfo.username }}</div>
      <div
        class="type"
        v-if="userInfo.userType == 0 || userInfo.userType == 1">
        <image
          src="../../static/icon/专家.svg"
          mode="aspectFit" />
      </div>
    </div>
    <!-- 个人信息列表 -->
    <div class="list">
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
    </div>
    <div class="btn">
      <div
        class="btn_logout"
        @click="logout">
        退出登录
      </div>
    </div>
  </div>
</template>

<script>
import NavBar from "../../components/NavBar/NavBar.vue";
import db from "../../utils/localStorage.js";
import { mapState } from "vuex";
import { globalParams } from "../../../public/config.js";

export default {
  components: {
    NavBar,
  },
  data() {
    return {
      title: "我的",
      defaultAvatar: "../../static/icon/头像.svg",
      globalParams,
    };
  },
  computed: {
    ...mapState(["userInfo"]),
  },
  methods: {
    logout() {
      db.clear();
      uni.reLaunch({ url: "/pages/login/login" });
    },
  },
  // 解决在微信小程序中 样式穿透无效的问题
  options: {
    styleIsolation: "shared",
  },
};
</script>

<style lang="scss" scoped>
.body {
  display: flex;
  flex-direction: column;
}

.info {
  height: 128px;
  display: flex;
  border-radius: 12px;
  background-color: #ffffff;
  box-shadow: 0px 4px 16px 0px #edeef0;
  align-items: center;
  margin: 16px;
  gap: 16px;
  .avatar {
    width: 64px;
    height: 64px;
    border-radius: 32px;
    margin-left: 16px;
    image {
      width: 100%;
      height: 100%;
      border-radius: 32px;
    }
  }
  .name {
    font-size: 16px;
    font-weight: 600;
  }
  .type {
    margin-left: auto;
    margin-right: 16px;
    width: 24px;
    height: 24px;
    image {
      width: 100%;
      height: 100%;
    }
  }
}
.list {
}
.btn {
  position: absolute;
  width: 100%;
  bottom: 16px;
  .btn_logout {
    height: 48px;
    margin: 0 16px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #ffffff;
    box-shadow: 0px 4px 16px 0px #edeef0;
    font-size: 16px;
    font-weight: 600;
    color: #1b54d9;

    &:active {
      background-color: #f2f2f2;
    }
  }
}
</style>
